/**
 * author:yjd
 */
nie.define('animate',function(){
  return {
    init:animateInit
  }
})
function animateInit(){
  var $win = $(window),
      winH = $win.height(),
      $animateEle = $('.scroll-ani'),
      animateLen = $animateEle.length;
      var scrollbind,
      resizebind;
      //小于IE9取消动画
      if($.browser.msie && parseInt($.browser.version) < 9){
        $animateEle.removeClass('scroll-ani');
        return;
      }
      scrollbind = function () {
        $.each($animateEle,function(index,ele){
          if(!ele.animated){
            if(winH > ele.getBoundingClientRect().top){
              $(ele).removeClass('scroll-ani');
              animateLen--;
              ele.animated = true;
            }
          }
        })
        if(!animateLen){
          $win.unbind('scroll',scrollbind);
          $win.unbind('resize',resizebind);
        }
      }

      $win.bind('scroll',scrollbind);
      
      resizebind = function () {
        winH = $win.height();
      }
      $win.bind('resize',resizebind);
      scrollbind()
}
